<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>AdWords API Documentation</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><link rel="stylesheet" href="../css/template.css" type="text/css"></link></head><body><div id="content"><h1 class="file">Common/Util/AuthToken.php</h1><div id="file-nav-box"><div id="file-nav-container"><ul id="file-nav"><li><a href="#classes"><img src="../images/icons/class.png" alt="Class" height="14"></img>
                          Classes
                      </a><ul><li><a href="#\AuthToken">\AuthToken</a></li></ul></li></ul><div style="clear: left;"></div></div><div id="file-nav-tab">
              Table of Contents
          </div></div><a name="top" class="anchor"></a><div id="file-description"><div class="short-description">Client used to retrieve authentication tokens from the Client Login API.</div><div class="long-description"></div></div><dl class="file-info"><dt>Author</dt><dd>Adam Rogal
         
    </dd><dt>Author</dt><dd>Eric Koleda
         
    </dd><dt>Author</dt><dd>Vincent Tsao
         
    </dd><dt>Category</dt><dd>WebServices
         
    </dd><dt>Copyright</dt><dd>2011, Google Inc. All Rights Reserved.
         
    </dd><dt>License</dt><dd>http://www.apache.org/licenses/LICENSE-2.0 Apache License,
            Version 2.0
         
    </dd><dt>Link</dt><dd><a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html">PHP version 5
Copyright 2011, Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</a>
         
    </dd><dt>Package</dt><dd>GoogleApiAdsCommon
         
    </dd><dt>Subpackage</dt><dd>Util
         
    </dd></dl><a name="classes" class="anchor"></a><a id="\AuthToken" class="anchor"></a><h2 class="class">\AuthToken<div class="to-top"><a href="#top">jump to top</a></div></h2><div class="class"><small class="package"><b>Package: </b>GoogleApiAdsCommon\Util</small><div class="short-description">Client used to retrieve authentication tokens from the Client Login API.</div><div class="long-description"></div><dl class="class-info"><dt>Link</dt><dd><a href="http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html">http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html</a>
         
    </dd></dl><h3>Constants</h3><div><a id="\AuthToken::DEFAULT_ACCOUNT_TYPE" class="anchor"></a><div class="constant publicC"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/constant.png" alt="Constant"></img>string 
                <span class="highlight">DEFAULT_ACCOUNT_TYPE</span>
                = 'GOOGLE'</code><div class="description"><div class="short-description">The default account type for authentication requests.</div></div><div class="code-tabs"><div class="long-description"></div><dl class="constant-info"><dt></dt><dd>string<br></br><em></em></dd></dl></div><div class="clear"></div></div><a id="\AuthToken::DEFAULT_SERVER" class="anchor"></a><div class="constant publicC"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/constant.png" alt="Constant"></img>string 
                <span class="highlight">DEFAULT_SERVER</span>
                = 'https://www.google.com'</code><div class="description"><div class="short-description">The default server to make authentication requests to.</div></div><div class="code-tabs"><div class="long-description"></div><dl class="constant-info"><dt></dt><dd>string<br></br><em></em></dd></dl></div><div class="clear"></div></div></div><h3>Properties</h3><div><a id="\AuthToken::$accountType" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$accountType</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\AuthToken::$captchaResponse" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$captchaResponse</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\AuthToken::$captchaToken" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$captchaToken</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\AuthToken::$curlUtils" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$curlUtils</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\AuthToken::$email" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$email</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\AuthToken::$password" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$password</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\AuthToken::$server" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$server</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\AuthToken::$service" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$service</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\AuthToken::$source" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$source</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div></div><h3>Methods</h3><div><a id="\AuthToken::GetAuthToken()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">GetAuthToken</span><span class="nb-faded-text">()</span> : string</code><div class="description"><p class="short_description">Peforms a POST to get the auth token and then parses the result.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>the auth token</td></tr></table><strong>Throws</strong><table class="argument-info"><thead><tr><th>Exception</th><th>Description</th></tr></thead><tr><td><a href="../files/Common.Util.AuthTokenException.html#\AuthTokenException">\AuthTokenException</a></td><td><em>if an error occurs during authentication</em></td></tr></table></div><div class="clear"></div></div><a id="\AuthToken::GetServer()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">GetServer</span><span class="nb-faded-text">()</span> : string</code><div class="description"><p class="short_description">Returns the server to make requests to.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>the server to make requests to</td></tr></table></div><div class="clear"></div></div><a id="\AuthToken::Login()" class="anchor"></a><div class="method private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">Login</span><span class="nb-faded-text">()</span> : string</code><div class="description"><p class="short_description">Makes the client login request and stores the result.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>the response from the ClientLogin API</td></tr></table><strong>Throws</strong><table class="argument-info"><thead><tr><th>Exception</th><th>Description</th></tr></thead><tr><td><a href="../files/Common.Util.AuthTokenException.html#\AuthTokenException">\AuthTokenException</a></td><td><em>if an error occurs during authentication</em></td></tr></table></div><div class="clear"></div></div><a id="\AuthToken::ParseResponse()" class="anchor"></a><div class="method private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">ParseResponse</span><span class="nb-faded-text">(string $response)</span> : array</code><div class="description"><p class="short_description">Parses the response into a map of field name to value.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$response</th><td>string</td><td><em><p>the response from the ClientLogin API</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>array</td><td>a map of field name to value</td></tr></table></div><div class="clear"></div></div><a id="\AuthToken::__construct()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">__construct</span><span class="nb-faded-text">(string $email, string $password, string $service, string $source, string $accountType = NULL, string $server = NULL, string $captchaToken = NULL, string $captchaResponse = NULL, <a href="../files/Common.Util.CurlUtils.html#\CurlUtils">\CurlUtils</a> $curlUtils = NULL)</span> : void</code><div class="description"><p class="short_description">Creates a new instance of this authentication token utility class.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$email</th><td>string</td><td><em><p>the email of the user</p></em></td></tr><tr><th>$password</th><td>string</td><td><em><p>the password of the user</p></em></td></tr><tr><th>$service</th><td>string</td><td><em><p>the service name</p></em></td></tr><tr><th>$source</th><td>string</td><td><em><p>the source name</p></em></td></tr><tr><th>$accountType</th><td>string</td><td><em><p>the account type, defaults to 'GOOGLE'</p>
</em></td></tr><tr><th>$server</th><td>string</td><td><em><p>the server to make the request to, defaults
    to 'https://www.google.com'</p>
</em></td></tr><tr><th>$captchaToken</th><td>string</td><td><em><p>captchaToken the token return with a CAPTCHA challenge</p></em></td></tr><tr><th>$captchaResponse</th><td>string</td><td><em><p>captchaResponse the response to a CAPTCHA challenge</p></em></td></tr><tr><th>$curlUtils</th><td><a href="../files/Common.Util.CurlUtils.html#\CurlUtils">\CurlUtils</a></td><td><em><p>an instance of CurlUtils</p></em></td></tr></table></div><div class="clear"></div></div></div></div></div><small class="footer">
            Documentation was generated by
            <a href="http://phpdoc.org">phpDocumentor
                2.0.0a12</a>.
        </small></body></html>
